﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using System.ServiceModel.DomainServices.Client;
using LEEAAttendanceControl.Web.Services;

namespace LEEAAttendanceControl.Views
{
    public partial class Overtime : Page
    {
        public Overtime()
        {
            InitializeComponent();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            App myApp = (App)Application.Current;

            myApp.ClearEvents();
        }

        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            WorkTimeDataSource.SubmittedChanges += OnChangesSubmitted;
          WorkTimeDataSource.SubmitChanges();
        }
        private void OnChangesSubmitted(object obj,SubmittedChangesEventArgs e)
        {
            if (e.HasError)
            {
                e.MarkErrorAsHandled();
                MessageBox.Show(ApplicationStrings.GeneralError, ApplicationStrings.GeneralError, MessageBoxButton.OK);
            }
            else
            {
                MessageBox.Show(ApplicationStrings.GeneralSave, ApplicationStrings.GeneralSave, MessageBoxButton.OK);
            }
        }
        private void WorkTimeDataSource_LoadingData(object sender, LoadingDataEventArgs e)
        {
            e.LoadBehavior = LoadBehavior.RefreshCurrent;
        }

    }
}
